/**
 *
 * Description: 
 *
 * @author lirong
 * @version 1.0
 * <pre>
 * Modification History: 
 * Date         Author      Version     Description 
 * ------------------------------------------------------------------ 
 * 2012-3-15    lirong       1.0        1.0 Version 
 * </pre>
 */

package com.creditease.rss.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 *
 * Description:
 *
 * @author lirong
 * @version 1.0
 *
 *          <pre>
 * Modification History: 
 * Date         Author      Version     Description 
 * ------------------------------------------------------------------ 
 * 2012-3-15    lirong       1.0        1.0 Version
 * </pre>
 */

public class StreamUtil {

    /**
     * 将输入流转换为字符串
     * Description:
     *
     * @param
     * @return String
     * @throws
     * @Author liong
     * Create Date: 2012-3-15 上午10:27:23
     */
    public static String stream2String(InputStream is) throws IOException {

        ByteArrayOutputStream oStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int index = 0;
        while ((index = is.read(buffer)) != -1) {
            oStream.write(buffer, 0, index);
        }

        String string=new String(oStream.toByteArray());
        oStream.close();
        return string;
    }
}
